package com.sq.partner.manager.service;

import java.util.List;
import java.util.Map;

import com.sq.partner.manager.mybatis.model.CoreDept;
import com.sq.partner.manager.mybatis.model.GatewayRole;
import com.sq.partner.manager.mybatis.model.GatewayUser;
import com.sq.partner.manager.mybatis.model.GatewayUserRole;
import com.sq.partner.manager.util.Page;

public interface IGatewayUserService {
	
	/**
	 * 分页查询
	 * @param page
	 * @param pageIndex
	 * @param user
	 * @return
	 * @throws Exception
	 */
	Page queryPage(Page page,Integer pageIndex,Map<String,String>param,GatewayUser user) throws Exception;
	
	/**
	 * 根据用户ID删除用户
	 * @param user
	 * @throws Exception
	 */
	void delUserById(Long userid) throws Exception;
	/**
	 * 删除用户角色表中用户ID
	 * @param userid
	 * @throws Exception
	 */
	public void delUserRoleUserid(Long   userid)throws Exception;
	
	/**
	 * 根据用户ID查询该用户信息
	 * @param userid
	 * @throws Exception
	 */
	GatewayUser queryUserById(Long userid) throws Exception;
	
	/**
	 * 保存用户信息
	 * @param user
	 * @throws Exception
	 */
	boolean saveUser(GatewayUser user) throws Exception;

	/**
	 * 修改密码
	 * @param user
	 * @throws Exception
	 */
	boolean modifyPwd(GatewayUser user) throws Exception;
	
	/**
	 * 获取用户角色
	 * @param userid
	 * @return
	 * @throws Exception
	 */
	List<GatewayRole> getUserRole(Long userid) throws Exception;
	
	/**
	 * 添加用户
	 * @param user
	 * @return
	 * @throws Exception
	 */
	boolean addUser(GatewayUser user) throws Exception;
	
	/**
	 * 根据条件查询用户个数
	 * @param map
	 * @return
	 * @throws Exception
	 */
	GatewayUser queryUserCount(Map<String,String> map) throws Exception;
	

	/**
	 * 查询所有角色
	 * @return
	 * @throws Exception
	 */
	List<GatewayRole> queryAllRoles(Map<String,String> map) throws Exception;
	
	
	/**
	 * 根据用户获取角色
	 * @param map
	 * @return
	 * @throws Exception
	 */
	List<GatewayRole> queryAllRolesByUser(GatewayUser user) throws Exception;

	/**
	 * 根据用户获取角色分页
	 * @param user
	 * @return
	 * @throws Exception
	 */
	Page queryRolesPageByUser(Page page,Integer pageIndex,Map<String,String> param,GatewayUser user) throws Exception;
	/**
	 * 给用户添加角色
	 * @return
	 * @throws Exception
	 */
	boolean setRoleToUser(GatewayUserRole role) throws Exception;

	/**
	 * 删除用户所有角色
	 * @return
	 * @throws Exception
	 */
	boolean removeAllRolesFromUser(Long userId) throws Exception;
	
	
	/**
	 * 查询某个角色有多少用户配置
	 * @param map
	 * @return
	 * @throws Exception
	 */
	List<GatewayUserRole> getUserCountOfOneRole(Map<String,Long> map) throws Exception;
	/**
	 * 查询用户的下级机构
	 * @param user
	 * @return
	 * @throws Exception
	 */
	List<CoreDept> queryDeptCode(GatewayUser user) throws Exception;
}
